export default {
  namespaced: true,
  state: {
    iframeList: [],
  },
  mutations: {
    SET_IFRAMELIST(state, route) {
      state.iframeList = [];
      state.iframeList.push(route);
    },
    PUSH_IFRAMELIST(state, route) {
      let target = state.iframeList.find((item) => item.path === route.path);
      if (!target) {
        state.iframeList.push(route);
      }
    },
    REMOVE_IFRAMELIST(state, route) {
      state.iframeList.forEach((item, index) => {
        if (item.path === route.path) {
          state.iframeList.splice(index, 1);
        }
      });
    },
    REFRESH_IFRAMELIST(state, route) {
      state.iframeList.forEach((item) => {
        if (item.path == route.path) {
          var url = route.meta.url;
          item.meta.url = "";
          setTimeout(function () {
            item.meta.url = url;
          }, 200);
        }
      });
    },
    CLEAR_IFRAMELIST(state) {
      state.iframeList = [];
    },
  },
};
